package com.aqie.easy.math;

/**
 * 453 最小移动次数使数组元素相等
 * todo
 */
public class MinMoves {
    public int minMoves(int[] nums) {
        if (nums.length == 1) return 0;
        int res = 0;
        int mininum = getMin(nums);
        for (int i : nums){
            res += i - mininum;
        }
        return res;
    }

    private static int getMin(int[] arr){
        int min = arr[0];
        for (int i = 1 ; i < arr.length; i++){
            if (min > arr[i]) min = arr[i];
        }
        return min;
    }
    public static void main(String[] args) {
        int[] arr = {1,2,3};

    }
}
